CC=g++ 

TARGET=plat
OBJS:=Screen.o aaScreen.o EventBoard.o Keyboard.o aaKeyboard.o
OBJS+=particle.o sdlScreen.o sprite.o sdlKeyboard.o 
OBJS+=list.o drawable.o animatedDrawble.o rect.o timer.o sdlTimer.o

AA_CFLAGS:=-I/usr/include
AA_LIBS:=-L/usr/lib -Wl,-rpath,/usr/lib -laa -lm -lgpm -lncurses

SDL_LIBS:= -lSDL -lpthread -lSDL_image 
SDL_CFLAGS:= -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL  

CFLAGS:= $(AA_CFLAGS) $(SDL_CFLAGS)
CFLAGS+= -Wall -g3

LIBS:= $(SDL_LIBS) $(AA_LIBS) -lm
#DEFINES:= -D DEBUG
DEFINES:=

CFLAGS+= $(DEFINES)

OBJ_DIR=obj

VPATH=obj

$(TARGET) : main.cc $(OBJS) debug.h
	 $(CC) $^ $(LIBS) -o $@ $(CFLAGS)

EventBoard.o: EventBoard.cc EventBoard.h debug.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)

#Keyboards
Keyboard.o: Keyboard.cc Keyboard.h debug.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)
aaKeyboard.o: aaKeyboard.cc aaKeyboard.h Keyboard.o debug.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)
sdlKeyboard.o: sdlKeyboard.cc sdlKeyboard.h Keyboard.o debug.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)

# Screens

Screen.o: Screen.cc Screen.h debug.h drawable.o animatedDrawble.o
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)
aaScreen.o: aaScreen.cc aaScreen.h Screen.o debug.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)
sdlScreen.o: sdlScreen.cc sdlScreen.h debug.h Screen.o debug.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)

#Rect
rect.o: rect.cc rect.h debug.h
	 $(CC) -c $< -o $@ $(CFLAGS)

#Sprite
sprite.o: sprite.cc sprite.h rect.o debug.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)
#sdlSprite.o: sdlSprite.cc sdlSprite.h sprite.o debug.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)
animatedDrawble.o: animatedDrawable.cc animatedDrawable.h sprite.o timer.o
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)


particle.o: particle.cc particle.h vector.h debug.h drawable.o list.o
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)

#Drawable
drawable.o: drawable.cc drawable.h sprite.o list.o rect.o
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)

#timers
timer.o: timer.cc timer.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)
sdlTimer.o: sdlTimer.cc sdlTimer.h timer.o
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)

list.o: list.cc list.h
	 $(CC) -c $< -o $(OBJ_DIR)/$@ $(CFLAGS)

debug:
	 ./generate.sh

clean:
	rm $(TARGET) $(OBJ_DIR)/*.o 

aaKeyboard.cc: ../../aaKeyboard.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

debug.h: ../../debug.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

list.cc: ../../list.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

Screen.h: ../../Screen.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sdlTimer.h: ../../sdlTimer.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

aaKeyboard.h: ../../aaKeyboard.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

drawable.cc: ../../drawable.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

list.h: ../../list.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sdlKeyboard.cc: ../../sdlKeyboard.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sprite.cc: ../../sprite.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

aaScreen.cc: ../../aaScreen.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

drawable.h: ../../drawable.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

main.cc: ../../main.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sdlKeyboard.h: ../../sdlKeyboard.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sprite.h: ../../sprite.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

aaScreen.h: ../../aaScreen.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

EventBoard.cc: ../../EventBoard.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

particle.cc: ../../particle.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sdlScreen.cc: ../../sdlScreen.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

timer.cc: ../../timer.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

animatedDrawable.cc: ../../animatedDrawable.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

EventBoard.h: ../../EventBoard.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

particle.h: ../../particle.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sdlScreen.h: ../../sdlScreen.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

timer.h: ../../timer.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

animatedDrawable.h: ../../animatedDrawable.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

field.h: ../../field.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

rect.cc: ../../rect.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sdlSprite.cc: ../../sdlSprite.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

vector.h: ../../vector.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

cKeyboard.cc: ../../cKeyboard.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

Keyboard.cc: ../../Keyboard.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

rect.h: ../../rect.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sdlSprite.h: ../../sdlSprite.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

cKeyboard.h: ../../cKeyboard.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

Keyboard.h: ../../Keyboard.h
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

Screen.cc: ../../Screen.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@

sdlTimer.cc: ../../sdlTimer.cc
	 ../proc.sed $< | cat ../proc.m4 - | m4 > $@
